<div class="generalText">

<h2>Javascript files Directory Structure</h2>

Currently there does not exist standard structure for javascript files directory. 
In here, I just follow the Java file structure and create a similar file structure 
for Javascript. 

<br><br>
As you see, I create a dir 'scripts' which is used to hold all of JS files. And I also
create a project related dir 'feyaSoft' which is used to hold all of my JS file. Any 
3rd-party JS lib are parallel to this dir - i.e: extjs.

<br><br>
Under dir 'feyaSoft', file 'feyaSoft.js' is used to define namespace for all of my JS files.
Any of my JS file will call it to define package. For example:
<br><br>
&nbsp; <font face="Courier New">package("feyaSoft.desktop");</font>
<br><br>

<b>Javascript package/public/private method</b>

<br><br>
Perhaps a very uncommon approach to developing web applications that require JavaScript 
is namespacing your scripts. And how to define a scope (public/private) to the method 
and variable. Here introduces a simple singleton pattern for achieving this 
discipline.

<br><br>
<font face="Courier New">
/**<br>
* Copyright(c) 2006-2007 ...<br>
*/<br>
package("FEYA.util");<br>

/**<br>
* This JS is used to define a bunch of util class<br>
*<br>
* @author fzhuang<br>
* @Date July 26, 2007<br>
*/<br>
FEYA.util.common = function(){<br>
&nbsp;    // private variable/function. Not accessible from outside<br>
&nbsp;    var count = 0;<br>
&nbsp;    var increaseCount = function(){count++;};<br>
<br>
&nbsp;    // Priviledged method. Can be called from outside<br>
&nbsp;    return {<br>
&nbsp; &nbsp;      formatDate: function(value){<br>
&nbsp; &nbsp; &nbsp;        return value ? value.dateFormat('D, M d Y') : '';<br>
&nbsp; &nbsp;      }<br>
&nbsp;    }<br>
&nbsp;}();<br>
</font>

</div>
<link href="/public/css/window/doc.css" rel="stylesheet" type="text/css">